package com.shopping.service.impl;

import com.shopping.bean.Category;
import com.shopping.bean.OrderProduct;
import com.shopping.bean.Product;
import com.shopping.dao.CategoryDao;
import com.shopping.dao.ProductDao;
import com.shopping.service.IProductService;
import com.shopping.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductService implements IProductService {
    @Autowired
    ProductDao productDao;


    @Override
    public int addProduct(Product product) {
        return productDao.addProduct(product);
    }

    @Override
    public int editProduct(Product product) {
        return productDao.editProduct(product);
    }

    @Override
    public int deleteProduct(int id) {
        return productDao.deleteProduct(id);
    }

    @Override
    public List<Product> getList(Page page, String text,String category) {
        return productDao.getList(page,text,category);
    }

    @Override
    public List<Product> getChildren(int id) {
        return productDao.getChildren(id);
    }

    @Override
    public Product getProductByID(Integer id) {
        return productDao.getProductByID(id);
    }

    @Override
    public int getCount(String text,String category) {
        return productDao.getCount(text,category);
    }

    @Override
    public List<Product> getProductsByCategoryName(String categoryname) {
        return productDao.getProductsByCategoryName(categoryname);
    }

    @Override
    public void updateStockAndSales(List<OrderProduct> orderProducts) {
        productDao.updateStockAndSales(orderProducts);
    }

    @Override
    public List<Product> getAllProductSalesAndStocks() {
        return productDao.getAllProductSalesAndStocks();
    }


}
